<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
    <title>员工管理</title>
    <%@include file="../common/header.jsp"%>

    <script>
        //页面加载后执行
        $(function () {
            //绑定点击事件
            $(".deleteBtn").click(function () {
                var ret = confirm("你确定要删除吗?");
                //如果结果为true,则执行
                if(ret){
                    $.get($(this).data("url"),function (data) {
                        if(data.success){
                            //刷新界面
                            window.location.reload();
                        }else{
                            alert(data,msg);
                        }
                    })
                }
            })
        })
    </script>
</head>
<body>
<!--左侧菜单回显变量设置-->
<c:set var="currentMenu" value="employee"/>
<div class="container " style="margin-top: 20px">
    <%@include file="../common/top.jsp"%>
    <div class="row">
        <div class="col-sm-2">
            <%@include file="../common/menu.jsp"%>
        </div>
        <div class="col-sm-10">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">员工管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/employee/list" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword}" placeholder="请输入姓名/邮箱">
                </div>
                <div class="form-group">
                    <label for="dept">部门:</label>
                    <select class="form-control" id="dept" name="deptId">
                        <option value="-1">全部</option>
                        <c:forEach var="d" items="${depts}">
                            <option value="${d.id}">${d.name}</option>
                        </c:forEach>
                    </select>

                </div>
                <button id="btn_query" class="btn btn-info"><span class="glyphicon glyphicon-search"></span> 查询</button>
                <a href="/employee/input" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span> 添加</a>
            </form>

            <table class="table table-striped table-hover" >
                <thead>
                    <tr>
                        <th>编号</th>
                        <th>名称</th>
                        <th>email</th>
                        <th>年龄</th>
                        <th>部门</th>
                       <%-- <th>角色</th>--%>
                        <th>操作</th>
                    </tr>
                </thead>
               <c:forEach items="${result.list}" var="entity" varStatus="vs">
                   <tr>
                       <td>${vs.count}</td>
                       <td>${entity.name}</td>
                       <td>${entity.email}</td>
                       <td>${entity.age}</td>
                       <td>${entity.dept.name}</td>
                       <td>
                           <a class="btn btn-info btn-xs" href="/employee/input?id=${entity.id}">
                               <span class="glyphicon glyphicon-pencil"></span> 编辑
                           </a>
                           <%--/employee/delete?id=${entity.id}--%>
                           <a href="javascript:;" class="btn btn-danger btn-xs deleteBtn" data-url="/employee/delete?id=${entity.id}">
                               <span class="glyphicon glyphicon-trash"></span> 删除
                           </a>
                       </td>
                   </tr>
               </c:forEach>
            </table>
            <!--包含分页插件-->
            <%@include file="../common/page.jsp"%>
        </div>
    </div>
</div>
</body>
</html>